<template>
	<view>
		<!--#ifdef H5 -->
		<cu-custom bgColor="bg-gradual-blue">
			<block slot="content">消息中心</block>
		</cu-custom>
		<!-- #endif -->
		<div class="">
			<ul class="mui-table-view mui-table-view-chevron">
				<li class="mui-table-view-cell mui-media" v-for="item in recentlyContacts">
					<a class="mui-navigate-right">
						<image class="mui-media-object mui-pull-left yuanjiao" :src="item.friendImg">
							<div class="mui-media-body">
								{{item.friendNickName}}
								<p class='mui-ellipsis'>{{item.Data}}</p>
							</div>
					</a>
				</li>
			</ul>
		</div>
	</view>
</template>
<script src="../js/mui.min.js"></script>
<script>
	import {
		setStorageSync,
		getStorageSync
	} from '@/utils/storage.js'
	export default {
		data() {
			return {
				myId: '',
				recentlyContacts: []
			}
		},
		mounted() {
				let that = this;
				//#ifdef APP-PLUS
				uni.$on('setItemEvent',function(e){
					console.log("aaaaaaaaaaaaaaaapp");
					console.log("eeeeeeeeeeeeeeeee:"+e);
					var model=e.newValue
					if (e.key === "myContacts_"+that.myId) {
						if(model.length!=0){
						that.recentlyContacts=	JSON.parse(model)
						}
					} 
				})
				//#endif
				//#ifdef H5
				console.log("hhhhhhhhhhhhhhhhhhhhh5");
				document.addEventListener("setItemEvent", function(e) {
					console.log("eeeeeeeeeeeeeeeeeeee2:"+e);
					var model=e.newValue
					if (e.key === "myContacts_"+that.myId) {
						if(model.length!=0){
						that.recentlyContacts=	JSON.parse(model)
						}
					} 
				})
				//#endif

		},
		created() {
			var that = this
			var user = getStorageSync('user')
			//setStorageSync("test",'test')
			this.myId = user.userId
			var contacts=getStorageSync("myContacts_"+this.myId)
			
			if(contacts===''){
			}else{
				this.recentlyContacts=JSON.parse(contacts)
				console.log("有缓存？");
			}
		},
		methods: {
		}
	}
</script>

<style>
	.yuanjiao {
		border-radius: 50%
	}
</style>
<style scoped>
	@import "../../static/css/app.css";
	@import "../../static/css/mui.min.css";
</style>
